home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / perl / sprite / perl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-14  |  20.5 KB  |  972 lines

  1. /* $RCSfile: perl.h,v $$Revision: 1.3 $$Date: 91/11/14 12:51:44 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    perl.h,v $
  9.  * Revision 1.3  91/11/14  12:51:44  jhh
  10.  * patchlevel 19
  11.  * 
  12.  * Revision 4.0.1.5  91/11/11  16:41:07  lwall
  13.  * patch19: uts wrongly defines S_ISDIR() et al
  14.  * patch19: too many preprocessors can't expand a macro right in #if
  15.  * patch19: added little-endian pack/unpack options
  16.  * 
  17.  * Revision 4.0.1.4  91/11/05  18:06:10  lwall
  18.  * patch11: various portability fixes
  19.  * patch11: added support for dbz
  20.  * patch11: added some support for 64-bit integers
  21.  * patch11: hex() didn't understand leading 0x
  22.  *
  23.  * Revision 1.2  91/07/16  17:02:58  jhh
  24.  * don't allow chroot()
  25.  * 
  26.  * Revision 1.1  91/07/15  23:16:12  jhh
  27.  * Initial revision
  28.  * 
  29.  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  30.  * patch10: certain pattern optimizations were botched
  31.  * 
  32.  * Revision 4.0.1.2  91/06/07  11:28:33  lwall
  33.  * patch4: new copyright notice
  34.  * patch4: made some allowances for "semi-standard" C
  35.  * patch4: many, many itty-bitty portability fixes
  36.  * 
  37.  * Revision 4.0.1.1  91/04/11  17:49:51  lwall
  38.  * patch1: hopefully straightened out some of the Xenix mess
  39.  * 
  40.  * Revision 4.0  91/03/20  01:37:56  lwall
  41.  * 4.0 baseline.
  42.  * 
  43.  */
  44.  
  45. #define VOIDWANT 1
  46. #include "config.h"
  47.  
  48. #ifdef MYMALLOC
  49. #   ifdef HIDEMYMALLOC
  50. #    define malloc Mymalloc
  51. #    define realloc Myremalloc
  52. #    define free Myfree
  53. #   endif
  54. #   define safemalloc malloc
  55. #   define saferealloc realloc
  56. #   define safefree free
  57. #endif
  58.  
  59. /* work around some libPW problems */
  60. #define fatal Myfatal
  61. #ifdef DOINIT
  62. char Error[1];
  63. #endif
  64.  
  65. #ifdef MSDOS
  66. /* This stuff now in the MS-DOS config.h file. */
  67. #else /* !MSDOS */
  68.  
  69. /*
  70.  * The following symbols are defined if your operating system supports
  71.  * functions by that name.  All Unixes I know of support them, thus they
  72.  * are not checked by the configuration script, but are directly defined
  73.  * here.
  74.  */
  75. #define HAS_ALARM
  76. #define HAS_CHOWN
  77. #ifndef sprite
  78. #define HAS_CHROOT
  79. #endif
  80. #define HAS_FORK
  81. #define HAS_GETLOGIN
  82. #define HAS_GETPPID
  83. #define HAS_KILL
  84. #define HAS_LINK
  85. #define HAS_PIPE
  86. #define HAS_WAIT
  87. #define HAS_UMASK
  88. /*
  89.  * The following symbols are defined if your operating system supports
  90.  * password and group functions in general.  All Unix systems do.
  91.  */
  92. #define HAS_GROUP
  93. #define HAS_PASSWD
  94.  
  95. #endif /* !MSDOS */
  96.  
  97. #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
  98. # define STANDARD_C 1
  99. #endif
  100.  
  101. #if defined(HASVOLATILE) || defined(STANDARD_C)
  102. #define VOLATILE volatile
  103. #else
  104. #define VOLATILE
  105. #endif
  106.  
  107. #ifdef IAMSUID
  108. #   ifndef TAINT
  109. #    define TAINT
  110. #   endif
  111. #endif
  112.  
  113. #ifndef HAS_VFORK
  114. #   define vfork fork
  115. #endif
  116.  
  117. #ifdef HAS_GETPGRP2
  118. #   ifndef HAS_GETPGRP
  119. #    define HAS_GETPGRP
  120. #   endif
  121. #   define getpgrp getpgrp2
  122. #endif
  123.  
  124. #ifdef HAS_SETPGRP2
  125. #   ifndef HAS_SETPGRP
  126. #    define HAS_SETPGRP
  127. #   endif
  128. #   define setpgrp setpgrp2
  129. #endif
  130.  
  131. #include <stdio.h>
  132. #include <ctype.h>
  133. #include <setjmp.h>
  134. #ifndef MSDOS
  135. #ifdef PARAM_NEEDS_TYPES
  136. #include <sys/types.h>
  137. #endif
  138. #include <sys/param.h>
  139. #endif
  140. #ifdef STANDARD_C
  141. /* Use all the "standard" definitions */
  142. #include <stdlib.h>
  143. #include <string.h>
  144. #endif /* STANDARD_C */
  145.  
  146. #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
  147. #undef HAS_MEMCMP
  148. #endif
  149.  
  150. #ifdef HAS_MEMCPY
  151.  
  152. #  ifndef STANDARD_C
  153. #    ifndef memcpy
  154. extern char * memcpy(), *memset();
  155. extern int memcmp();
  156. #    endif /* ndef memcpy */
  157. #  endif /* ndef STANDARD_C */
  158.  
  159. #   ifndef bcopy
  160. #    define bcopy(s1,s2,l) memcpy(s2,s1,l)
  161. #   endif
  162. #   ifndef bzero
  163. #    define bzero(s,l) memset(s,0,l)
  164. #   endif
  165. #endif /* HAS_MEMCPY */
  166.  
  167. #ifndef HAS_BCMP        /* prefer bcmp slightly 'cuz it doesn't order */
  168. #   ifndef bcmp
  169. #    define bcmp(s1,s2,l) memcmp(s1,s2,l)
  170. #   endif
  171. #endif
  172.  
  173. #ifndef _TYPES_        /* If types.h defines this it's easy. */
  174. #ifndef major        /* Does everyone's types.h define this? */
  175. #include <sys/types.h>
  176. #endif
  177. #endif
  178.  
  179. #ifdef I_NETINET_IN
  180. #include <netinet/in.h>
  181. #endif
  182.  
  183. #include <sys/stat.h>
  184. #ifdef uts
  185. #undef S_ISDIR
  186. #undef S_ISCHR
  187. #undef S_ISBLK
  188. #undef S_ISREG
  189. #undef S_ISFIFO
  190. #undef S_ISLNK
  191. #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
  192. #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
  193. #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
  194. #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
  195. #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
  196. #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
  197. #endif
  198.  
  199. #ifdef I_TIME
  200. #   include <time.h>
  201. #endif
  202.  
  203. #ifdef I_SYS_TIME
  204. #   ifdef SYSTIMEKERNEL
  205. #    define KERNEL
  206. #   endif
  207. #   include <sys/time.h>
  208. #   ifdef SYSTIMEKERNEL
  209. #    undef KERNEL
  210. #   endif
  211. #endif
  212.  
  213. #ifndef MSDOS
  214. #include <sys/times.h>
  215. #endif
  216.  
  217. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  218. #undef HAS_STRERROR
  219. #endif
  220.  
  221. #include <errno.h>
  222. #ifndef MSDOS
  223. #ifndef errno
  224. extern int errno;     /* ANSI allows errno to be an lvalue expr */
  225. #endif
  226. #endif
  227.  
  228. #ifndef strerror
  229. #ifdef HAS_STRERROR
  230. char *strerror();
  231. #else
  232. extern int sys_nerr;
  233. extern char *sys_errlist[];
  234. #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  235. #endif
  236. #endif
  237.  
  238. #ifdef I_SYSIOCTL
  239. #ifndef _IOCTL_
  240. #include <sys/ioctl.h>
  241. #endif
  242. #endif
  243.  
  244. #if defined(mc300) || defined(mc500) || defined(mc700)    /* MASSCOMP */
  245. #ifdef HAS_SOCKETPAIR
  246. #undef HAS_SOCKETPAIR
  247. #endif
  248. #ifdef HAS_NDBM
  249. #undef HAS_NDBM
  250. #endif
  251. #endif
  252.  
  253. #ifdef WANT_DBZ
  254. #include <dbz.h>
  255. #define SOME_DBM
  256. #define dbm_fetch(db,dkey) fetch(dkey)
  257. #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
  258. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  259. #define dbm_close(db) dbmclose()
  260. #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  261. #define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
  262. #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  263. #ifdef HAS_NDBM
  264. #undef HAS_NDBM
  265. #endif
  266. #ifndef HAS_ODBM
  267. #define HAS_ODBM
  268. #endif
  269. #else
  270. #ifdef HAS_GDBM
  271. #ifdef I_GDBM
  272. #include <gdbm.h>
  273. #endif
  274. #define SOME_DBM
  275. #ifdef HAS_NDBM
  276. #undef HAS_NDBM
  277. #endif
  278. #ifdef HAS_ODBM
  279. #undef HAS_ODBM
  280. #endif
  281. #else
  282. #ifdef HAS_NDBM
  283. #include <ndbm.h>
  284. #define SOME_DBM
  285. #ifdef HAS_ODBM
  286. #undef HAS_ODBM
  287. #endif
  288. #else
  289. #ifdef HAS_ODBM
  290. #ifdef NULL
  291. #undef NULL        /* suppress redefinition message */
  292. #endif
  293. #include <dbm.h>
  294. #ifdef NULL
  295. #undef NULL
  296. #endif
  297. #define NULL 0        /* silly thing is, we don't even use this */
  298. #define SOME_DBM
  299. #define dbm_fetch(db,dkey) fetch(dkey)
  300. #define dbm_delete(db,dkey) delete(dkey)
  301. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  302. #define dbm_close(db) dbmclose()
  303. #define dbm_firstkey(db) firstkey()
  304. #endif /* HAS_ODBM */
  305. #endif /* HAS_NDBM */
  306. #endif /* HAS_GDBM */
  307. #endif /* WANT_DBZ */
  308. #ifdef SOME_DBM
  309. EXT char *dbmkey;
  310. EXT int dbmlen;
  311. #endif
  312.  
  313. #if INTSIZE == 2
  314. #define htoni htons
  315. #define ntohi ntohs
  316. #else
  317. #define htoni htonl
  318. #define ntohi ntohl
  319. #endif
  320.  
  321. #if defined(I_DIRENT)
  322. #   include <dirent.h>
  323. #   define DIRENT dirent
  324. #else
  325. #   ifdef I_SYS_NDIR
  326. #    include <sys/ndir.h>
  327. #    define DIRENT direct
  328. #   else
  329. #    ifdef I_SYS_DIR
  330. #        ifdef hp9000s500
  331. #        include <ndir.h>    /* may be wrong in the future */
  332. #        else
  333. #        include <sys/dir.h>
  334. #        endif
  335. #        define DIRENT direct
  336. #    endif
  337. #   endif
  338. #endif
  339.  
  340. #ifdef FPUTS_BOTCH
  341. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  342. #   ifndef fputs
  343. #    define fputs(str,fp) fprintf(fp,"%s",str)
  344. #   endif
  345. #endif
  346.  
  347. /*
  348.  * The following gobbledygook brought to you on behalf of __STDC__.
  349.  * (I could just use #ifndef __STDC__, but this is more bulletproof
  350.  * in the face of half-implementations.)
  351.  */
  352.  
  353. #ifndef S_IFMT
  354. #   ifdef _S_IFMT
  355. #    define S_IFMT _S_IFMT
  356. #   else
  357. #    define S_IFMT 0170000
  358. #   endif
  359. #endif
  360.  
  361. #ifndef S_ISDIR
  362. #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  363. #endif
  364.  
  365. #ifndef S_ISCHR
  366. #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  367. #endif
  368.  
  369. #ifndef S_ISBLK
  370. #   ifdef S_IFBLK
  371. #    define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  372. #   else
  373. #    define S_ISBLK(m) (0)
  374. #   endif
  375. #endif
  376.  
  377. #ifndef S_ISREG
  378. #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  379. #endif
  380.  
  381. #ifndef S_ISFIFO
  382. #   ifdef S_IFIFO
  383. #    define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  384. #   else
  385. #    define S_ISFIFO(m) (0)
  386. #   endif
  387. #endif
  388.  
  389. #ifndef S_ISLNK
  390. #   ifdef _S_ISLNK
  391. #    define S_ISLNK(m) _S_ISLNK(m)
  392. #   else
  393. #    ifdef _S_IFLNK
  394. #        define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  395. #    else
  396. #        ifdef S_IFLNK
  397. #        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  398. #        else
  399. #        define S_ISLNK(m) (0)
  400. #        endif
  401. #    endif
  402. #   endif
  403. #endif
  404.  
  405. #ifndef S_ISSOCK
  406. #   ifdef _S_ISSOCK
  407. #    define S_ISSOCK(m) _S_ISSOCK(m)
  408. #   else
  409. #    ifdef _S_IFSOCK
  410. #        define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  411. #    else
  412. #        ifdef S_IFSOCK
  413. #        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  414. #        else
  415. #        define S_ISSOCK(m) (0)
  416. #        endif
  417. #    endif
  418. #   endif
  419. #endif
  420.  
  421. #ifndef S_IRUSR
  422. #   ifdef S_IREAD
  423. #    define S_IRUSR S_IREAD
  424. #    define S_IWUSR S_IWRITE
  425. #    define S_IXUSR S_IEXEC
  426. #   else
  427. #    define S_IRUSR 0400
  428. #    define S_IWUSR 0200
  429. #    define S_IXUSR 0100
  430. #   endif
  431. #   define S_IRGRP (S_IRUSR>>3)
  432. #   define S_IWGRP (S_IWUSR>>3)
  433. #   define S_IXGRP (S_IXUSR>>3)
  434. #   define S_IROTH (S_IRUSR>>6)
  435. #   define S_IWOTH (S_IWUSR>>6)
  436. #   define S_IXOTH (S_IXUSR>>6)
  437. #endif
  438.  
  439. #ifndef S_ISUID
  440. #   define S_ISUID 04000
  441. #endif
  442.  
  443. #ifndef S_ISGID
  444. #   define S_ISGID 02000
  445. #endif
  446.  
  447. #ifdef f_next
  448. #undef f_next
  449. #endif
  450.  
  451. #if defined(cray) || defined(gould)
  452. #   define SLOPPYDIVIDE
  453. #endif
  454.  
  455. #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
  456. #   define QUAD
  457. #endif
  458.  
  459. #ifdef QUAD
  460. #   ifdef cray
  461. #    define quad int
  462. #   else
  463. #    if defined(convex) || defined (uts)
  464. #        define quad long long
  465. #    else
  466. #        define quad long
  467. #    endif
  468. #   endif
  469. #endif
  470.  
  471. typedef unsigned int STRLEN;
  472.  
  473. typedef struct arg ARG;
  474. typedef struct cmd CMD;
  475. typedef struct formcmd FCMD;
  476. typedef struct scanpat SPAT;
  477. typedef struct stio STIO;
  478. typedef struct sub SUBR;
  479. typedef struct string STR;
  480. typedef struct atbl ARRAY;
  481. typedef struct htbl HASH;
  482. typedef struct regexp REGEXP;
  483. typedef struct stabptrs STBP;
  484. typedef struct stab STAB;
  485. typedef struct callsave CSV;
  486.  
  487. #include "handy.h"
  488. #include "regexp.h"
  489. #include "str.h"
  490. #include "util.h"
  491. #include "form.h"
  492. #include "stab.h"
  493. #include "spat.h"
  494. #include "arg.h"
  495. #include "cmd.h"
  496. #include "array.h"
  497. #include "hash.h"
  498.  
  499. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  500. #   define I286
  501. #endif
  502.  
  503. #ifndef    STANDARD_C
  504. #ifdef CHARSPRINTF
  505.     char *sprintf();
  506. #else
  507.     int sprintf();
  508. #endif
  509. #endif
  510.  
  511. EXT char *Yes INIT("1");
  512. EXT char *No INIT("");
  513.  
  514. /* "gimme" values */
  515.  
  516. /* Note: cmd.c assumes that it can use && to produce one of these values! */
  517. #define G_SCALAR 0
  518. #define G_ARRAY 1
  519.  
  520. #ifdef CRIPPLED_CC
  521. int str_true();
  522. #else /* !CRIPPLED_CC */
  523. #define str_true(str) (Str = (str), \
  524.     (Str->str_pok ? \
  525.         ((*Str->str_ptr > '0' || \
  526.           Str->str_cur > 1 || \
  527.           (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
  528.     : \
  529.         (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
  530. #endif /* CRIPPLED_CC */
  531.  
  532. #ifdef DEBUGGING
  533. #define str_peek(str) (Str = (str), \
  534.     (Str->str_pok ? \
  535.         Str->str_ptr : \
  536.         (Str->str_nok ? \
  537.         (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
  538.             (char*)tokenbuf) : \
  539.         "" )))
  540. #endif
  541.  
  542. #ifdef CRIPPLED_CC
  543. char *str_get();
  544. #else
  545. #ifdef TAINT
  546. #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
  547.     (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  548. #else
  549. #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  550. #endif /* TAINT */
  551. #endif /* CRIPPLED_CC */
  552.  
  553. #ifdef CRIPPLED_CC
  554. double str_gnum();
  555. #else /* !CRIPPLED_CC */
  556. #ifdef TAINT
  557. #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
  558.     (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  559. #else /* !TAINT */
  560. #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  561. #endif /* TAINT*/
  562. #endif /* CRIPPLED_CC */
  563. EXT STR *Str;
  564.  
  565. #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
  566.  
  567. #ifndef MSDOS
  568. #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
  569. #define Str_Grow str_grow
  570. #else
  571. /* extra parentheses intentionally NOT placed around "len"! */
  572. #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
  573.         str_grow(str,(unsigned long)len)
  574. #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
  575. #endif /* MSDOS */
  576.  
  577. #ifndef BYTEORDER
  578. #define BYTEORDER 0x1234
  579. #endif
  580.  
  581. #if defined(htonl) && !defined(HAS_HTONL)
  582. #define HAS_HTONL
  583. #endif
  584. #if defined(htons) && !defined(HAS_HTONS)
  585. #define HAS_HTONS
  586. #endif
  587. #if defined(ntohl) && !defined(HAS_NTOHL)
  588. #define HAS_NTOHL
  589. #endif
  590. #if defined(ntohs) && !defined(HAS_NTOHS)
  591. #define HAS_NTOHS
  592. #endif
  593. #ifndef HAS_HTONL
  594. #if (BYTEORDER & 0xffff) != 0x4321
  595. #define HAS_HTONS
  596. #define HAS_HTONL
  597. #define HAS_NTOHS
  598. #define HAS_NTOHL
  599. #define MYSWAP
  600. #define htons my_swap
  601. #define htonl my_htonl
  602. #define ntohs my_swap
  603. #define ntohl my_ntohl
  604. #endif
  605. #else
  606. #if (BYTEORDER & 0xffff) == 0x4321
  607. #undef HAS_HTONS
  608. #undef HAS_HTONL
  609. #undef HAS_NTOHS
  610. #undef HAS_NTOHL
  611. #endif
  612. #endif
  613.  
  614. /*
  615.  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  616.  * -DWS
  617.  */
  618. #if BYTEORDER != 0x1234
  619. # define HAS_VTOHL
  620. # define HAS_VTOHS
  621. # define HAS_HTOVL
  622. # define HAS_HTOVS
  623. # if BYTEORDER == 0x4321
  624. #  define vtohl(x)    ((((x)&0xFF)<<24)    \
  625.             +(((x)>>24)&0xFF)    \
  626.             +(((x)&0x0000FF00)<<8)    \
  627.             +(((x)&0x00FF0000)>>8)    )
  628. #  define vtohs(x)    ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  629. #  define htovl(x)    vtohl(x)
  630. #  define htovs(x)    vtohs(x)
  631. # endif
  632.     /* otherwise default to functions in util.c */
  633. #endif
  634.  
  635. #ifdef CASTNEGFLOAT
  636. #define U_S(what) ((unsigned short)(what))
  637. #define U_I(what) ((unsigned int)(what))
  638. #define U_L(what) ((unsigned long)(what))
  639. #else
  640. unsigned long castulong();
  641. #define U_S(what) ((unsigned int)castulong(what))
  642. #define U_I(what) ((unsigned int)castulong(what))
  643. #define U_L(what) (castulong(what))
  644. #endif
  645.  
  646. CMD *add_label();
  647. CMD *block_head();
  648. CMD *append_line();
  649. CMD *make_acmd();
  650. CMD *make_ccmd();
  651. CMD *make_icmd();
  652. CMD *invert();
  653. CMD *addcond();
  654. CMD *addloop();
  655. CMD *wopt();
  656. CMD *over();
  657.  
  658. STAB *stabent();
  659. STAB *genstab();
  660.  
  661. ARG *stab2arg();
  662. ARG *op_new();
  663. ARG *make_op();
  664. ARG *make_match();
  665. ARG *make_split();
  666. ARG *rcatmaybe();
  667. ARG *listish();
  668. ARG *maybelistish();
  669. ARG *localize();
  670. ARG *fixeval();
  671. ARG *jmaybe();
  672. ARG *l();
  673. ARG *fixl();
  674. ARG *mod_match();
  675. ARG *make_list();
  676. ARG *cmd_to_arg();
  677. ARG *addflags();
  678. ARG *hide_ary();
  679. ARG *cval_to_arg();
  680.  
  681. STR *str_new();
  682. STR *stab_str();
  683.  
  684. int do_each();
  685. int do_subr();
  686. int do_match();
  687. int do_unpack();
  688. int eval();        /* this evaluates expressions */
  689. int do_eval();        /* this evaluates eval operator */
  690. int do_assign();
  691.  
  692. SUBR *make_sub();
  693.  
  694. FCMD *load_format();
  695.  
  696. char *scanpat();
  697. char *scansubst();
  698. char *scantrans();
  699. char *scanstr();
  700. char *scanident();
  701. char *str_append_till();
  702. char *str_gets();
  703. char *str_grow();
  704.  
  705. bool do_open();
  706. bool do_close();
  707. bool do_print();
  708. bool do_aprint();
  709. bool do_exec();
  710. bool do_aexec();
  711.  
  712. int do_subst();
  713. int cando();
  714. int ingroup();
  715.  
  716. void str_replace();
  717. void str_inc();
  718. void str_dec();
  719. void str_free();
  720. void stab_clear();
  721. void do_join();
  722. void do_sprintf();
  723. void do_accept();
  724. void do_pipe();
  725. void do_vecset();
  726. void do_unshift();
  727. void do_execfree();
  728. void magicalize();
  729. void magicname();
  730. void savelist();
  731. void saveitem();
  732. void saveint();
  733. void savelong();
  734. void savesptr();
  735. void savehptr();
  736. void restorelist();
  737. void repeatcpy();
  738. HASH *savehash();
  739. ARRAY *saveary();
  740.  
  741. EXT char **origargv;
  742. EXT int origargc;
  743. EXT char **origenviron;
  744. extern char **environ;
  745.  
  746. EXT long subline INIT(0);
  747. EXT STR *subname INIT(Nullstr);
  748. EXT int arybase INIT(0);
  749.  
  750. struct outrec {
  751.     long    o_lines;
  752.     char    *o_str;
  753.     int        o_len;
  754. };
  755.  
  756. EXT struct outrec outrec;
  757. EXT struct outrec toprec;
  758.  
  759. EXT STAB *stdinstab INIT(Nullstab);
  760. EXT STAB *last_in_stab INIT(Nullstab);
  761. EXT STAB *defstab INIT(Nullstab);
  762. EXT STAB *argvstab INIT(Nullstab);
  763. EXT STAB *envstab INIT(Nullstab);
  764. EXT STAB *sigstab INIT(Nullstab);
  765. EXT STAB *defoutstab INIT(Nullstab);
  766. EXT STAB *curoutstab INIT(Nullstab);
  767. EXT STAB *argvoutstab INIT(Nullstab);
  768. EXT STAB *incstab INIT(Nullstab);
  769. EXT STAB *leftstab INIT(Nullstab);
  770. EXT STAB *amperstab INIT(Nullstab);
  771. EXT STAB *rightstab INIT(Nullstab);
  772. EXT STAB *DBstab INIT(Nullstab);
  773. EXT STAB *DBline INIT(Nullstab);
  774. EXT STAB *DBsub INIT(Nullstab);
  775.  
  776. EXT HASH *defstash;        /* main symbol table */
  777. EXT HASH *curstash;        /* symbol table for current package */
  778. EXT HASH *debstash;        /* symbol table for perldb package */
  779.  
  780. EXT STR *curstname;        /* name of current package */
  781.  
  782. EXT STR *freestrroot INIT(Nullstr);
  783. EXT STR *lastretstr INIT(Nullstr);
  784. EXT STR *DBsingle INIT(Nullstr);
  785. EXT STR *DBtrace INIT(Nullstr);
  786. EXT STR *DBsignal INIT(Nullstr);
  787.  
  788. EXT int lastspbase;
  789. EXT int lastsize;
  790.  
  791. EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  792. EXT char *origfilename;
  793. EXT FILE * VOLATILE rsfp;
  794. EXT char buf[1024];
  795. EXT char *bufptr;
  796. EXT char *oldbufptr;
  797. EXT char *oldoldbufptr;
  798. EXT char *bufend;
  799.  
  800. EXT STR *linestr INIT(Nullstr);
  801.  
  802. EXT char *rs INIT("\n");
  803. EXT int rschar INIT('\n');    /* final char of rs, or 0777 if none */
  804. EXT int rslen INIT(1);
  805. EXT char *ofs INIT(Nullch);
  806. EXT int ofslen INIT(0);
  807. EXT char *ors INIT(Nullch);
  808. EXT int orslen INIT(0);
  809. EXT char *ofmt INIT(Nullch);
  810. EXT char *inplace INIT(Nullch);
  811. EXT char *nointrp INIT("");
  812.  
  813. EXT bool preprocess INIT(FALSE);
  814. EXT bool minus_n INIT(FALSE);
  815. EXT bool minus_p INIT(FALSE);
  816. EXT bool minus_l INIT(FALSE);
  817. EXT bool minus_a INIT(FALSE);
  818. EXT bool doswitches INIT(FALSE);
  819. EXT bool dowarn INIT(FALSE);
  820. EXT bool doextract INIT(FALSE);
  821. EXT bool allstabs INIT(FALSE);    /* init all customary symbols in symbol table?*/
  822. EXT bool sawampersand INIT(FALSE);    /* must save all match strings */
  823. EXT bool sawstudy INIT(FALSE);        /* do fbminstr on all strings */
  824. EXT bool sawi INIT(FALSE);        /* study must assume case insensitive */
  825. EXT bool sawvec INIT(FALSE);
  826. EXT bool localizing INIT(FALSE);    /* are we processing a local() list? */
  827.  
  828. #ifndef MAXSYSFD
  829. #   define MAXSYSFD 2
  830. #endif
  831. EXT int maxsysfd INIT(MAXSYSFD);    /* top fd to pass to subprocesses */
  832.  
  833. #ifdef CSH
  834. char *cshname INIT(CSH);
  835. int cshlen INIT(0);
  836. #endif /* CSH */
  837.  
  838. #ifdef TAINT
  839. EXT bool tainted INIT(FALSE);        /* using variables controlled by $< */
  840. #endif
  841.  
  842. #ifndef MSDOS
  843. #define TMPPATH "/tmp/perl-eXXXXXX"
  844. #else
  845. #define TMPPATH "plXXXXXX"
  846. #endif /* MSDOS */
  847. EXT char *e_tmpname;
  848. EXT FILE *e_fp INIT(Nullfp);
  849.  
  850. EXT char tokenbuf[256];
  851. EXT int expectterm INIT(TRUE);        /* how to interpret ambiguous tokens */
  852. EXT VOLATILE int in_eval INIT(FALSE);    /* trap fatal errors? */
  853. EXT int multiline INIT(0);        /* $*--do strings hold >1 line? */
  854. EXT int forkprocess;            /* so do_open |- can return proc# */
  855. EXT int do_undump INIT(0);        /* -u or dump seen? */
  856. EXT int error_count INIT(0);        /* how many errors so far, max 10 */
  857. EXT int multi_start INIT(0);        /* 1st line of multi-line string */
  858. EXT int multi_end INIT(0);        /* last line of multi-line string */
  859. EXT int multi_open INIT(0);        /* delimiter of said string */
  860. EXT int multi_close INIT(0);        /* delimiter of said string */
  861.  
  862. FILE *popen();
  863. /* char *str_get(); */
  864. STR *interp();
  865. void free_arg();
  866. STIO *stio_new();
  867. void hoistmust();
  868. void scanconst();
  869.  
  870. EXT struct stat statbuf;
  871. EXT struct stat statcache;
  872. STAB *statstab INIT(Nullstab);
  873. STR *statname;
  874. #ifndef MSDOS
  875. EXT struct tms timesbuf;
  876. #endif
  877. EXT int uid;
  878. EXT int euid;
  879. EXT int gid;
  880. EXT int egid;
  881. UIDTYPE getuid();
  882. UIDTYPE geteuid();
  883. GIDTYPE getgid();
  884. GIDTYPE getegid();
  885. EXT int unsafe;
  886.  
  887. #ifdef DEBUGGING
  888. EXT VOLATILE int debug INIT(0);
  889. EXT int dlevel INIT(0);
  890. EXT int dlmax INIT(128);
  891. EXT char *debname;
  892. EXT char *debdelim;
  893. #define YYDEBUG 1
  894. #endif
  895. EXT int perldb INIT(0);
  896. #define YYMAXDEPTH 300
  897.  
  898. EXT line_t cmdline INIT(NOLINE);
  899.  
  900. EXT STR str_undef;
  901. EXT STR str_no;
  902. EXT STR str_yes;
  903.  
  904. /* runtime control stuff */
  905.  
  906. EXT struct loop {
  907.     char *loop_label;        /* what the loop was called, if anything */
  908.     int loop_sp;        /* stack pointer to copy stuff down to */
  909.     jmp_buf loop_env;
  910. } *loop_stack;
  911.  
  912. EXT int loop_ptr INIT(-1);
  913. EXT int loop_max INIT(128);
  914.  
  915. EXT jmp_buf top_env;
  916.  
  917. EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
  918.  
  919. struct ufuncs {
  920.     int (*uf_val)();
  921.     int (*uf_set)();
  922.     int uf_index;
  923. };
  924.  
  925. EXT ARRAY *stack;        /* THE STACK */
  926.  
  927. EXT ARRAY * VOLATILE savestack;        /* to save non-local values on */
  928.  
  929. EXT ARRAY *tosave;        /* strings to save on recursive subroutine */
  930.  
  931. EXT ARRAY *lineary;        /* lines of script for debugger */
  932. EXT ARRAY *dbargs;        /* args to call listed by caller function */
  933.  
  934. EXT ARRAY *fdpid;        /* keep fd-to-pid mappings for mypopen */
  935. EXT HASH *pidstatus;        /* keep pid-to-status mappings for waitpid */
  936.  
  937. EXT int *di;            /* for tmp use in debuggers */
  938. EXT char *dc;
  939. EXT short *ds;
  940.  
  941. /* Fix these up for __STDC__ */
  942. EXT long basetime INIT(0);
  943. char *mktemp();
  944. #ifndef STANDARD_C
  945. /* All of these are in stdlib.h or time.h for ANSI C */
  946. double atof();
  947. long time();
  948. struct tm *gmtime(), *localtime();
  949. char *index(), *rindex();
  950. char *strcpy(), *strcat();
  951. #endif /* ! STANDARD_C */
  952.  
  953. #ifdef EUNICE
  954. #define UNLINK unlnk
  955. int unlnk();
  956. #else
  957. #define UNLINK unlink
  958. #endif
  959.  
  960. #ifndef HAS_SETREUID
  961. #ifdef HAS_SETRESUID
  962. #define setreuid(r,e) setresuid(r,e,-1)
  963. #define HAS_SETREUID
  964. #endif
  965. #endif
  966. #ifndef HAS_SETREGID
  967. #ifdef HAS_SETRESGID
  968. #define setregid(r,e) setresgid(r,e,-1)
  969. #define HAS_SETREGID
  970. #endif
  971. #endif
  972.